/**
 *  
 * 音效处理类
 * 可处理多个音效一起播放
 * 播放一次，声音音量为1
 */
class SoundEffect extends BaseSound{
    
    /** 播放次数 */
    private loop:number;
    public constructor() {
        super();
        this.volume = 1;
        this.loop =1;
	}
	
    public static get get(): SoundEffect{
        return SoundEffect.getInstance();
	}
	
	/**
	 * 播放音乐
	 * @param source 音乐资源的位置
	 * @param loop 是否循环，小于等于0无限循环
	 */
    public play(source: string,loop=this.loop): void {
        var sound = this.getSound(source);
        this.playSound(sound,loop);
    }
	
	/**
	 * 复写父类方法，如果加载成功则执行
	 * @param source 资源名称
	 */
    public loadedPlay(source: string): void {
        super.loadedPlay(source);
        this.play(source);
    }
    
    public static test():void {
//        var effect = new SoundEffect();
        var source = "effect_doorclose_1_mp3";
//        Log.d("sourd url :"+source);
        SoundEffect.get.play(source);
//        Log.d("sound has cache:" + effect.isCache(source) +",sound loading:" + effect.isSoundResLoading(source)); 
        
        Log.n();
        source = "effect_pageopen_1_mp3";
        SoundEffect.get.play(source,1); 
//        Log.d("sourd url :" + source);
//        Log.d("sound has cache:" + effect.isCache(source) + ",sound loading:" + effect.isSoundResLoading(source)); 
        
    }
}
